package org.logic.membershipFunctions;

public abstract class AMembershipFunction {

	double x1; // min
	double x2; // left top
	double x3; // right top
	double x4; // max
	double h; // height
	
	public double getMembershipDegree(double value) {
		
	     if (value < x1 || value > x4) {
	            return 0.0;
	        }
	     
	        double degree;
	        if (value < x2) {
	            degree = h * (x2 - value) / (x2 - x1);
	        } else if (value > x3) {
	            degree = h * (value - x3) / (x4 - x3);
	        } else {
	            return h;
	        }
	        return 1 - degree;
	}
	
}
